/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */
define(['adminapp'], function ($app) {

    $app.navactive('repart_booking');

    var action_tpl = Handlebars.compile($(g.actiontpl).html());

    $app.listtable(
        {
            'sAjaxSource'  : g.ctx + "admin/booking/dining/list",
            'aoColumns'    : [
                $app.autono,
                {'mDataProp': 'name', 'bSortable': false},
                {'mDataProp': 'floor' },
                {'mDataProp': 'location', 'bSortable': false},
                {'mDataProp': 'consumption' }
            ],
            'aoColumnDefs' : [
                {
                    'aTargets': [1],
                    'mData'   : null,
                    'mRender' : function (data, type, full) {
                        var name = full['name'];
                        return !(!name || name == 'null') ? name : full['e_name'];
                    }
                },
                {
                    'aTargets': [2],
                    'mData'   : null,
                    'mRender' : function (data, type, full) {
                        return full['floor_name'];
                    }
                },
                {
                    'aTargets': [5],
                    'mData'   : null,
                    'mRender' : function (data, type, full) {
                        return action_tpl(full);
                    }
                }
            ],
            'fnRowCallback': function (nRow, aData, iDisplayIndex) {
                var oSettings = this.fnSettings();
                $("td:eq(0)", nRow).html(oSettings._iDisplayStart + iDisplayIndex + 1);
                return nRow;
            }
        },
        'dining-list');
    return {};
});